package com.lu.dog.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class ThrowableUtil {
    public static String convert2String(Throwable th) throws IOException {
        if (th == null) {
            return "";
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            th.printStackTrace(new PrintStream(baos));
        } finally {
            baos.close();
        }
        return baos.toString();
    }

}
